//用于设置请求地址
export const base="http://localhost:3000/api/competition";
//暴露设置option的函数
export function getOption(method,body={},header={"Content-Type":"application/json"}){
    let option={
        method:method,
        headers:header,
        mode:'cors'
    }
    if(method!=='get'){
        option={
            ...option,
            body:JSON.stringify(body)}
    }
    return option
}
export function stringify(data={}) {
    let _result = [];
    for (let key in data) {
        let value = data[key];
        if (value.constructor === Array) {
            value.forEach(function(_value) {
                _result.push(key + "=" + _value);
            });
        } else {
            _result.push(key + '=' + value);
        }
    }
    return _result.join('&');
}